/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2018-2019.
 * Description: support huawei e500mc boards function, like setup_arch and init_IRQ
 * Author: liuwenliang <liuwenliang@huawei.com>
 * Create: 2018-12-22
 */

#include <linux/kernel.h>
#include <linux/pci.h>
#include <linux/kdev_t.h>
#include <linux/delay.h>
#include <linux/interrupt.h>

#include <asm/time.h>
#include <asm/machdep.h>
#include <asm/pci-bridge.h>
#include <asm/pgtable.h>
#include <asm/ppc-pci.h>
#include <mm/mmu_decl.h>
#include <asm/prom.h>
#include <asm/udbg.h>
#include <asm/mpic.h>
#include <asm/ehv_pic.h>
#include <asm/cacheflush.h>
#include <linux/of_platform.h>
#include <sysdev/fsl_soc.h>
#include <sysdev/fsl_pci.h>
#include <asm/uaccess.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/memblock.h>

#include "smp.h"
#include "mpc85xx.h"
#include "rtos_ppc_board.h"

#ifdef CONFIG_RTOS_PPC_DYING_INT
#include <asm/rtos_dying_int.h>
#endif

#ifdef CONFIG_HISI_WATCHDOG
#include <linux/hal/watchdog.h>
#endif

/*
 * Called very early, device-tree isn't unflattened
 */
static int __init p40XX_mpu_probe(void)
{
	unsigned long root = of_get_flat_dt_root();

	if (of_flat_dt_is_compatible(root, "huawei,P40XX_MPU"))
		return 1;

	return 0;
}

void __init e500mc_board_setup_arch(void)
{
	corenet_gen_setup_arch();
}

define_machine(P40XX_MPU) {
	.name			= "huawei,P40XX_MPU",
	.probe			= p40XX_mpu_probe,
	.setup_arch		= e500mc_board_setup_arch,
	.init_IRQ		= corenet_gen_pic_init,
#ifdef CONFIG_PCI
	.pcibios_fixup_bus	= fsl_pcibios_fixup_bus,
#endif
	.get_irq		= mpic_get_coreint_irq,
	.calibrate_decr		= generic_calibrate_decr,
	.progress		= udbg_progress,
	.power_save		= e500_idle,
};
machine_arch_initcall(P40XX_MPU, corenet_gen_publish_devices);
